package miiteen.customsportal.Api;


import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import miiteen.core.result.ResultMessage;
import miiteen.core.result.ResultMessageTool;
import miiteen.customsportal.basic.beans.BasicBillboards;
import miiteen.customsportal.basic.service.BasicBillboardsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 宣传栏
 *
 */
@Api(tags = "宣传栏")
@RestController
@RequestMapping("/Api/basicBillboards")
@CrossOrigin
public class BasicBillboardsApiController {

    @Autowired
    private BasicBillboardsService basicBillboardsService;

    @GetMapping("findByList")
    @ApiOperation("列表页面")
    public ResultMessage GetList(){

        List<BasicBillboards> list=basicBillboardsService.findListByMap();

        if(list!=null && list.size()>0){
            return ResultMessageTool.Success("success",list);
        }
        return ResultMessageTool.Error("未找到相关信息！");
    }

    @GetMapping("findById")
    @ApiOperation("详情页面")
    public ResultMessage GetOne(String id){
        if(id!=null){
            BasicBillboards basicBillboards=basicBillboardsService.findById(Long.valueOf(id));
            if(basicBillboards!=null){
                return ResultMessageTool.Success("success",basicBillboards);
            }
            return ResultMessageTool.Error("未找到该条信息！");
        }
        return ResultMessageTool.Error("未接收到参数！");
    }
}
